package au.com.darkside.XServer;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

import android.net.LocalServerSocket;
import android.net.LocalSocket;
import android.util.Log;


public class UnixSocket extends Socket{
	Socket s = new Socket();
	private LocalServerSocket lServerSocket;
	private LocalSocket		  lSocket;

	public UnixSocket(String string) throws IOException
	{
	    lServerSocket = new LocalServerSocket(string);
		Log.e("UnixSock","constructed");
	}

	public void accept() throws IOException
	{
		Log.e("UnixSock","about to block");
	    lSocket=lServerSocket.accept();
	}
	
	@Override
	public OutputStream getOutputStream() throws IOException
	{
		return lSocket.getOutputStream();
	}
	
	@Override
	public InputStream getInputStream() throws IOException
	{
		return lSocket.getInputStream();
	}
	
	@Override
	public void close() throws IOException
	{
		lSocket.close();
		Log.e("UnixSock","closeSocket");
	}
	
	public void closeServer() throws IOException
	{
		lServerSocket.close();
		Log.e("UnixSock","closeServer");
	}
}
